# plugins/weather.py WeatherPlugin
from datetime import datetime 
import requests 
from  PluginBase import PluginBase, tool

class Weather(PluginBase):
    @tool(description="获取城市实时温度", city="城市名称")
    def get_weather_temp(city: str) -> str:
        try:
            response = requests.get(f"https://wttr.in/{city}?format=%t", timeout=3)
            return f"{city}当前温度：{response.text.strip()}"
        except Exception as e:
            return f"天气查询失败：{str(e)}"
''' 
    @tool(description="比较两个城市温度", city1="第一个城市", city2="第二个城市")
    def get_weather_compare_cities(self, city1: str, city2: str) -> str: 
        t1 = self.get_weather(city1)
        t2 = self.get_weather(city2)
'''